package com.lzh.chatnote.common.mqConsumer;

import com.lzh.chatnote.common.constant.MQConstant;
import com.lzh.chatnote.common.domain.dto.ScanLoginDTO;
import com.lzh.chatnote.webSocket.service.WebSocketService;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@RocketMQMessageListener(consumerGroup = MQConstant.SCAN_MSG_GROUP, topic = MQConstant.SCAN_MSG_TOPIC, messageModel = MessageModel.BROADCASTING)
public class ScanLoginConsumer implements RocketMQListener<ScanLoginDTO> {

    @Resource
    private WebSocketService webSocketService;

    @Override
    public void onMessage(ScanLoginDTO scanLoginDTO) {
        System.out.println("消費 ====>" + scanLoginDTO);
        //todo 发送给前段消息进行登录确认
        webSocketService.sureLoginHandle(scanLoginDTO);
    }
}
